/* ====================================================================
 * (#)Header: UserServiceImpl.java
 * (#)Revision: 
 * (#)Date Created: 22-Mar-08 12:47:15 AM
 * (#)Created By: Karol Wozniak
 * ====================================================================
 *
 * Copyright (c) 2007 karolak .  All rights reserved.
 *
 * ====================================================================
 * 
 * The software application represented here is the sole property of 
 * karolak. Its unauthorized utilization is expressly prohibited.
 * 
 * ====================================================================
 */
package com.karolak.service.entity.app;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.karolak.entity.app.User;
import com.karolak.query.Criterias;
import com.karolak.service.entity.GenericPersonServiceImpl;
import com.karolak.service.entity.app.UserService;

/**
 * 
 * <code>UserServiceImpl</code> is ....
 * 
 * @author <a href="mailto:kwozniak@hotmail.com">Karol Wozniak</a>
 */

public class UserServiceImpl extends GenericPersonServiceImpl<User> implements UserService {

	public UserServiceImpl() {
		super(User.class);
	}

	@Override
	public User findById(Integer id) {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("id", id);
		User user = getDao().find("User.selectUserById", paramMap);
		return user;
	}

	public User findByUserName(String userName) {
		Criterias criterias = new Criterias();
		criterias.add("userName", "=", userName);
		return getDao().find(getPersistentClass(), criterias);
	}

	public List<User> selectByUserName(String userName) {
		Criterias criterias = new Criterias();
		criterias.add("userName", "like", userName);
		return getDao().select(getPersistentClass(), criterias);
	}

	public List<User> selectByRoleName(String roleName) {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("roleName", roleName);
		return getDao().select("User.selectByRoleName", paramMap);
	}
}
